{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "9b2d3ed2-cb97-4e1a-ad8d-01c51ca9f03a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n"
     ]
    }
   ],
   "source": [
    "import openai\n",
    "import os\n",
    "openai.api_key = os.getenv(\"OPENAI_API_KEY\")\n",
    "\n",
    "content_to_classify = \"the driver was involved in a car accident with several explosions\"\n",
    "\n",
    "response = openai.Completion.create(\n",
    "      model=\"content-filter-alpha\",\n",
    "      prompt = \"<|endoftext|>\"+content_to_classify+\"\\n--\\nLabel:\",\n",
    "      temperature=0,\n",
    "      max_tokens=1,\n",
    "      top_p=0,\n",
    "      logprobs=10\n",
    "    )\n",
    "\n",
    "print(response.choices[0].text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "f8981bc6-d933-4f4d-8c09-3f6dfa23489f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import openai\n",
    "\n",
    "embedding = openai.Embedding.create(\n",
    "    input=\"The cat is on the table\", model=\"text-embedding-ada-002\")[\"data\"][0][\"embedding\"]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ac518d9b-7ab5-40dc-98fe-1992ca969c2a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[-0.01369840931147337,\n",
       " -0.007505378685891628,\n",
       " -0.002576263388618827,\n",
       " -0.014773285016417503,\n",
       " 0.019935185089707375,\n",
       " -0.01802290789783001,\n",
       " -0.01594814844429493,\n",
       " -0.0010944041423499584,\n",
       " -0.014323337003588676]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "embedding[1:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d9c04e5e-c666-4789-abc6-4b333572ac41",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
